import os

import gradio as gr

# 定义变量
URL = "http://127.0.0.1:8188/prompt"
INPUT_DIR = "D:\PycharmProjects\ComfyUI\ComfyUI\input"
OUTPUT_DIR = "D:\PycharmProjects\ComfyUI\ComfyUI\output"

#获取文件夹下的所有工作流的文件
def get_all_workflow_files_arr(workflow_path):
    files = os.listdir(workflow_path)
    workflow_arr = [f for f in files if f.lower().endswith(('.json', '.JSON'))]
    return workflow_arr

# v2
def index_box():
    with gr.Blocks(analytics_enabled=False) as index:
        gr.Markdown("<div align='center'>"
                    " <h1>ComfyUI_Easy_Link</h1>"
                    "<h3>作者：Xik</h3>"
                    "</div>")

        demo=gr.Dropdown(get_all_workflow_files_arr("./workflows"),type="value")
        img=gr.Video()
        btn=gr.Button("sad")
        btn.click(
            fn=demo1,
            inputs=[demo,img]

        )
    return index
def demo1(*demo):
    print(demo[1])

if __name__ == "__main__":
    index = index_box()
    index.queue()
    index.launch()
